export default{
  namespaced:true,
  state:()=>({
    token: uni.getStorageSync('token') || '',
    userinfo: JSON.parse(uni.getStorageSync('userinfo') || '{}')
  }),
  mutations:{
    updateUserInfo(state,userinfo){
      state.userinfo = userinfo
      this.commit('m_user/saveUserInfoToStorage')
    },
    
    saveUserInfoToStorage(state){
      uni.setStorageSync('userinfo',JSON.stringify((state.userinfo)))
    },
    
    saveTokenToStorage(state){
      uni.setStorageSync('token',state.token)
    },
    
    updateToken(state,token){
      state.token=token
      this.commit('m_user/saveTokenToStorage')
    }
  },
  getters:{}
}